/*
  Copyright © 2011  Vinícius dos Santos Oliveira

  This file is part of Vinipsmaker's HTTP tools.

  Vinipsmaker's HTTP tools is free software: you can redistribute it and/or
  modify it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or (at your
  option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#include "urlcodecdialog.h"
#include "ui_urlcodecdialog.h"
#include <QUrl>

UrlCodecDialog::UrlCodecDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::UrlCodecDialog)
{
    ui->setupUi(this);
}

UrlCodecDialog::~UrlCodecDialog()
{
    delete ui;
}

void UrlCodecDialog::on_copyButton_clicked()
{
    ui->plainTextEdit->selectAll();
    ui->plainTextEdit->copy();
}

void UrlCodecDialog::on_pasteButton_clicked()
{
    if (ui->plainTextEdit->canPaste()) {
        ui->plainTextEdit->clear();
        ui->plainTextEdit->paste();
    }
}

void UrlCodecDialog::on_decodeButton_clicked()
{
    ui->textBrowser->setPlainText(QUrl::fromPercentEncoding(ui->plainTextEdit->toPlainText().toUtf8()));
}

void UrlCodecDialog::on_encodeButton_clicked()
{
    ui->textBrowser->setPlainText(QUrl::toPercentEncoding(ui->plainTextEdit->toPlainText()));
}

void UrlCodecDialog::on_copyResultsButton_clicked()
{
    ui->textBrowser->selectAll();
    ui->textBrowser->copy();
}
